/**
 * Created by wry on 2015/3/17.
 */
'use strict';

angular.module('backofficeApp.backendHome.controllers', []).
    controller('backendHomeCtrl', ['$scope', '$location', '$http', '$interval', function ($scope, $location, $http, $interval) {

        $scope.statistics = {
            noReply: 0,
            report: 0,
            authentication: 0,
            feedback: 0,
            supplement: 0,
            user: 0,
            question: 0,
            reply: 0
        };

        $scope.$watch('$viewContentLoaded', function () {
            $scope.getStatistics();
        });

        $scope.getStatistics = function () {
            $http.get('http://' + backOfficeHost + '/rest/v1.0/backoffice/Systems/getAllCommunityStatistics', {
                headers: {'Content-Type': 'application/json;charset=utf-8'}
            }).success(function (result) {
                $scope.statistics = result.data;
                //if ($scope.statistics.noReply > 0 || $scope.statistics.authentication > 0) {
                //    var myVideo = document.getElementById("bg");
                //    if (myVideo != null) {
                //        myVideo.play();
                //    }
                //}
            }).error(function () {
            });
        };
        $interval($scope.getStatistics, 300000);
    }]);